#include "widgetui.h"
#include "ui_widgetui.h"

WidgetUI::WidgetUI(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::WidgetUI)
{
    ui->setupUi(this);
    ui->horizontalSlider->setValue(ui->battery->powerLevel());
}

WidgetUI::~WidgetUI()
{
    delete ui;
}

void WidgetUI::on_horizontalSlider_valueChanged(int value)
{
    //滑动改变电量值
    ui->battery->setPowerLevel(value);

    QString str = QStringLiteral("当前电量：%1 %").arg(value);

    ui->label_curPowStr->setText(str);
}

